﻿<%@ Page Title="用户" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="ListUsers.aspx.cs" Inherits="Manage_ListUsers" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
    <%
        if (Page.User.Identity.IsAuthenticated == false)
        {
            Response.Redirect("~/Manage/Default.aspx");
        }     
    %>
    <script type="text/javascript">
        function DeleteUser() {
            if (confirm('确认删除当前用户信息吗？')) {
                return true;
            } else {
                return false;
            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    <asp:Literal ID="ErrorText" runat="server"></asp:Literal>
    <div style="margin:5px 0px 5px 0px">
        <asp:GridView ID="UsersView" runat="server" AllowPaging="True" 
            AutoGenerateColumns="False" BackColor="White" BorderColor="#CCCCCC" 
            BorderStyle="None" BorderWidth="1px" CellPadding="3" 
            DataSourceID="UserDataSource">
            <Columns>
                <asp:TemplateField>
                    <ItemStyle Width="50px" HorizontalAlign="Center" />
                    <ItemTemplate>
                        <asp:LinkButton ID="DeleteButton" runat="server" Text="删除" CommandArgument='<%#Eval("ID") %>' OnClientClick="return DeleteUser();" OnCommand="Command_DeleteUser" />
                    </ItemTemplate>
                </asp:TemplateField>
                
                <asp:TemplateField HeaderText="用户名">
                    <ItemStyle Width="200px" />
                    <ItemTemplate>
                        <a href='./EditUser.aspx?uid=<%#Eval("ID") %>'><%#Eval("Name") %></a>
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText="管理栏目">
                    <ItemStyle Width="80px" HorizontalAlign="Center" />
                    <ItemTemplate>
                        <a href='./ListForums.aspx?uid=<%#Eval("ID") %>'><%#Eval("Forums.Count") %></a>
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText="发表文章">
                    <ItemStyle Width="80px" HorizontalAlign="Center" />
                    <ItemTemplate>
                        <a href='./ListArticles.aspx?uid=<%#Eval("ID") %>'><%#Eval("Articles.Count") %></a>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <FooterStyle BackColor="White" ForeColor="#000066" />
            <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
            <RowStyle ForeColor="#000066" />
            <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
            <SortedAscendingCellStyle BackColor="#F1F1F1" />
            <SortedAscendingHeaderStyle BackColor="#007DBB" />
            <SortedDescendingCellStyle BackColor="#CAC9C9" />
            <SortedDescendingHeaderStyle BackColor="#00547E" />
        </asp:GridView>
        <asp:LinqDataSource ID="UserDataSource" runat="server" 
            ContextTypeName="TreasurerDataContext" EntityTypeName="" 
            Select="new (ID, Name, Articles, Forums)" TableName="Users">
        </asp:LinqDataSource>
    </div>

    
    <asp:LinkButton ID="NewUserButton" runat="server" Text="增加用户" 
        onclick="NewUserButton_Click" />
</asp:Content>

